package BehaviorDesignPattern.IteratorPattern;

import BehaviorDesignPattern.IteratorPattern.interfase.Iterator;

import java.util.ArrayList;
import java.util.List;

public class ConcreteIterator implements Iterator {
    private List<Object> list;
    private int position;

    public ConcreteIterator(List<Object> list) {
        this.list = list;
        this.position = 0;
    }

    @Override
    public boolean hasNext() {
        return position < list.size();
    }

    @Override
    public Object next() {
        if (hasNext()){
            return list.get(position++);
        }
        return null;
    }
}
